const acl = require("express-acl");

module.exports = ({ env, db }) => {
  const unlessPath = ["/login", "/init"].map(
    (el) => `${env.ROUTE_BASE_PATH}${el}`
  );
  const rules = db.get("rules").value();
  acl.config({
    rules,
    decodedObjectName: "auth",
  });
  return acl.authorize.unless({ path: unlessPath });
};
